<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <my-button type="primary">主要按钮</my-button>
    <my-button type="success">成功按钮</my-button>
  </div>
  <script>
    let component = {
      props: {
        type: {
          type: String,
          default: 'primary'
        }
      },
      data() {
        return {
          obj: {
            primary: {
              backgroundColor: '#409eff',
              border: 0,
              borderRadius: '2px',
              width: '97px',
              height: '40px',
              color: 'white'
            },
            success: {
              backgroundColor: '#67c23a',
              border: 0,
              borderRadius: '2px',
              width: '97px',
              height: '40px',
              color: 'white'
            }
          }
        }
      },
      template: `
        <button :style="obj[type]">
          <slot></slot>  
        </button>
      `
    }
    let vm = new Vue({
      el: "#app",
      data: {

      },
      methods: {

      },
      created() {

      },
      components: {
        myButton: component
      }
    })
  </script>
</body>

</html>